package junit;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import analyser.DataAnalyser;
import analyser.impl.DataAnalyserImpl;
import comparetor.CustomerComparetorByBirth;
import comparetor.CustomerComparetorById;
import pojo.Customer;

public class TestCustomerListOrder 
{
	private DataAnalyser da;
	private List<Customer> list;

	@Before
	public void init() {
		 list=new ArrayList<Customer>();
		
		 Customer c1=new Customer("5", "john", "true", "john@163.com", "1995-09-20");
		 Customer c2=new Customer("3", "tom", "flase", "tom@163.com", "1995-09-29");
		 Customer c3=new Customer("7", "alice", "false", "tom@163.com", "1995-07-29");
		 list.add(c1);
		 list.add(c2);
		 list.add(c3);
		
		 da=new DataAnalyserImpl(list);
	}

	@Test
	public void testAnalyse() {
		Comparator<Customer> comp = new CustomerComparetorById();
		Comparator<Customer> comp1 = new CustomerComparetorByBirth();
		Set<Customer> cs1 = da.analyse(comp);
		Set<Customer> cs2 = da.analyse(comp1);
		for (Customer c : cs1) {
			System.out.println(c.getId());
		}
		for (Customer c : cs2) 
		{
			System.out.println(c.getDate());
		}
	}

}
